#ifndef BLOOM_SAMPLE_H
#define BLOOM_SAMPLE_H

#include "SampleBase.h"
#include "plane.h"
#include "sphere.h"
#include "glslprogram.h"
#include "objmesh.h"
#include "Quad.h"
#include <glm\glm.hpp>

using glm::vec3;
using glm::vec4;
using glm::mat3;
using glm::mat4;

namespace ShaderLab {
	class BloomSample : public SampleBase {
	public:
		BloomSample();
		~BloomSample();

		void Init();
		void Update(float time);
		void Render();
		void Imgui();
		void ShutDown();
	private:
		void UpdateMatrices();
		void CreateShader();
		void FBO();
		void Pass1();
		void Pass2();
		void Pass3();
		void Pass4();
		void Pass5();
		float Gauss(float, float);
		void DrawScene();
		void ComputeLuminance();
	private:
		GLSLProgram program;
		GLuint hdrFbo, blurFbo;
		GLuint hdrTex, tex1, tex2;
		GLuint linearSampler, nearestSampler;
		int bloomBufWidth, bloomBufHeight;
		std::unique_ptr<Plane> plane;
		std::unique_ptr<Sphere> sphere;
		std::unique_ptr<ObjMesh> mesh;
		std::unique_ptr<Quad> screenQuad;
		mat4 model, view, projection;
		float bloomScale;
	};
}
#endif // !TEMPLATE_SAMPLE_H
